package com.hongxinguoji.manager.younger.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hongxinguoji.manager.younger.mapper.HxOutstandingEmployeeMapper;
import com.hongxinguoji.manager.younger.pojo.HxOutstandingEmployee;
import com.hongxinguoji.manager.younger.pojo.HxOutstandingEmployeeExample;
import com.hongxinguoji.manager.younger.service.IOutstandingEmployeeService;

@Service
public class OutstandingEmployeeServiceImpl implements IOutstandingEmployeeService {

	@Autowired
	private HxOutstandingEmployeeMapper outstandingEmployeeMapper;

	@Override
	public void addYoung(HxOutstandingEmployee outstandingEmployee) {

		outstandingEmployeeMapper.insert(outstandingEmployee);

	}

	@Override
	public List<HxOutstandingEmployee> getYoungList() {
		HxOutstandingEmployeeExample example = new HxOutstandingEmployeeExample();
		List<HxOutstandingEmployee> list = outstandingEmployeeMapper.selectByExample(example);
		return list;
	}

	@Override
	public void lockYoung(Long i) {
		HxOutstandingEmployee outstandingEmployee = outstandingEmployeeMapper.selectByPrimaryKey(i);
		outstandingEmployee.setStatus(0);

		outstandingEmployeeMapper.updateByPrimaryKey(outstandingEmployee);

	}

	@Override
	public void unlockYoung(Long i) {
		HxOutstandingEmployee outstandingEmployee = outstandingEmployeeMapper.selectByPrimaryKey(i);
		outstandingEmployee.setStatus(1);

		outstandingEmployeeMapper.updateByPrimaryKey(outstandingEmployee);

	}

	@Override
	public void deleteYoung(Long i) {
		outstandingEmployeeMapper.deleteByPrimaryKey(i);

	}

	@Override
	public void updateContent(HxOutstandingEmployee employee) {
		Long id = employee.getId();
		HxOutstandingEmployee outstandingEmployee = outstandingEmployeeMapper.selectByPrimaryKey(id);

		outstandingEmployee.setHeaderImg(employee.getHeaderImg());
		outstandingEmployee.setLiveImg(employee.getLiveImg());
		outstandingEmployee.setMotto(employee.getMotto());
		outstandingEmployee.setName(employee.getName());
		outstandingEmployee.setPosition(employee.getPosition());
		outstandingEmployee.setType(employee.getType());
		outstandingEmployee.setUpdateDate(new Date());

		outstandingEmployeeMapper.updateByPrimaryKey(outstandingEmployee);

	}

}
